package com.binhai.rolem;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.binhai.rolem.RoleBean;
import com.binhai.rolem.RoleBeanMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 72645
 * @description 针对表【t_role】的数据库操作Service实现
 * @createDate 2025-04-19 08:57:57
 */
@Service
public class RoleBeanServiceImpl extends ServiceImpl<RoleBeanMapper, RoleBean>
{
    @Autowired
    private RoleBeanMapper roleBeanMapper;

    public List getAllInfos() {
        return roleBeanMapper.selectList(null);
    }

    public Map saveInfo(RoleBean role) {
        Map map = new HashMap();
        try {
            // 插入数据
            roleBeanMapper.insert(role);
            map.put("result","success");
            return map;
        }
        catch (Exception e){
            e.printStackTrace();
            map.put("result","error");
            return map;
        }
    }

    public Map deleteInfo(int id) {
        Map map = new HashMap();
        try {
            roleBeanMapper.deleteById(id);
            map.put("result","success");
            return map;
        }
        catch (Exception e){
            e.printStackTrace();
            map.put("result","error");
            return map;
        }
    }

    public Map updateInfo(RoleBean role) {
        Map map = new HashMap();
        try {
            roleBeanMapper.updateById(role);
            map.put("result","success");
            return map;
        }
        catch (Exception e){
            e.printStackTrace();
            map.put("result","error");
            return map;
        }
    }

    public RoleBean getInfoById(int id) {
        return    roleBeanMapper.selectById(id);
    }
}




